#ifndef __I386_STDLIB_H__
#define __I386_STDLIB_H__

#ifdef __cplusplus
extern "C" {
#endif

#ifndef NULL
    #define NULL 0L
#endif

#define RAND_MAX        2147483647

//typedef unsigned long size_t;

#ifndef __cplusplus
typedef int wchar_t;
#endif

long strtoi(char *s,int base,char **scan_end);
unsigned long strtou(char *s,int base,char **scan_end);
double strtod(char *s,char **scan_end);
long strtol(const char *nptr, char **endptr, int base);
unsigned long strtoul(const char *nptr, char **endptr, int base);

unsigned ecvt(double v,char *buffer,int width,int prec,int flag);
unsigned fcvt(double v,char *buffer,int width,int prec,int flag);
unsigned gcvt(double v,char *buffer,int width,int prec,int flag);
unsigned dcvt(long long v,char *buffer,int base,int width,int flag);
unsigned ucvt(unsigned long long v,char *buffer,int base,int width,int flag);

#define atof(s)	strtod(s, NULL);
#define atoi(s)	strtoi(s, 10, NULL);
#define atou(s)	strtou(s, 10, NULL);
#define atol(s) strtol(s, 10, NULL);

void srand(long int seed);
long int rand(void);
unsigned abs(int x);

void exit(int code);

#if !defined(__max)
#define __max(a,b)  (((a) > (b)) ? (a) : (b))
#endif
#if !defined(max) /*&& !defined(__cplusplus)*/
#define max(a,b)  (((a) > (b)) ? (a) : (b))
#endif
#if !defined(__min)
#define __min(a,b)  (((a) < (b)) ? (a) : (b))
#endif
#if !defined(min) /*&& !defined(__cplusplus)*/
#define min(a,b)  (((a) < (b)) ? (a) : (b))
#endif

#ifdef __cplusplus
}
#endif

#endif
